package com.deng.report;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.deng.common.SQLHelper;

public class KS_M_001 extends SQLHelper {


	private int y;
	private int m;
	private String user_id;
	private int kaohe_id;
	private Connection conn;
	public KS_M_001(int y,int m,String user_id,int kaohe_id){
		this.y = y;
		this.m = m;
		this.user_id = user_id;
		this.kaohe_id = kaohe_id;
	}
	
	//编号,指标,满分,实际得分
	public List<String[]> getReport(){
		try{
			if(conn == null || conn.isClosed())
				conn = getConnect();
			
			String sql = "select * from KPI_VS_ORGANIZATION";
			Statement st =  conn.createStatement();
			ResultSet rs =st.executeQuery(sql);
			while(rs.next()){
				System.out.println(rs.getString(1));
			}
			rs.close();
			st.close();
			conn.close();
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return null;
	}
	
	public List<String[]> getMyDivision(){
		List<String[]> l = new ArrayList<String[]>();
		try{
			if(conn == null || conn.isClosed())
				conn = getConnect();
			
			String sql = "select d.id,td.name+'-'+d.name from "+
				" t_sys_users_vs_department as uvd " +
				" left join t_sys_stat_department as d on uvd.organization_id = d.id"+
				" left join DICT_DUTY_TYPE as td on td.id = d.duty_id"+
				" where code = '"+user_id+"'";
			Statement st =  conn.createStatement();
			ResultSet rs =st.executeQuery(sql);
			String[] s;
			while(rs.next()){
				System.out.println(rs.getString(1));
				s = new String[2];
				s[0] = rs.getInt(1)+"";
				s[2] = rs.getString(2);
				l.add(s);
			}
			rs.close();
			st.close();
			conn.close();			
		}catch(Exception ex){
			ex.printStackTrace();
		}
		if(l.size() != 0){
			l.add(0, new String[]{"all","全部"});
		}
		return l;
	}
	
}
